<template>
  <div>
    <el-form label-width="100px">
      <el-form-item label="角色名称:">
        <el-input size="medium" style="width: 350px;" v-model="roleName"></el-input>
      </el-form-item>
      <el-form-item label="角色编码:">
        <el-input size="medium" style="width: 350px;" v-model="rolecode"></el-input>
      </el-form-item>
      <el-form-item label="订单时间:" size="normal">
        <el-date-picker v-model="timeArr" value-format="yyyy-MM-dd" clearable>
        </el-date-picker>

      </el-form-item>
      <el-form-item label="备注:">
        <el-input v-model="roleNote" size="medium" style="width: 350px;"></el-input>
      </el-form-item>
    </el-form>
    <el-button type="primary" size="medium" @click=submitRoles>确定</el-button>
  </div>
</template>

<script>
export default {
  props: {
    id: {
      required: true
    },
  },
  data() {
    return {
      roleName: '',
      rolecode: '',
      timeArr: '',
      roleNote: '',
      sort: ''
    }
  },
  mounted() {
    this.getSelectRoles()
  },
  methods: {
    async getSelectRoles() {
      let res = await this.$API.SystemMenus.reqRolesById(this.id)
      if (res.code == 200) {
        this.roleName = res.data.rolename;
        this.rolecode = res.data.rolecode;
        this.timeArr = res.data.createtime;
        this.roleNote = res.data.notes;
        this.sort = res.data.sort
      }
    },
    submitRoles() {
      this.updateSystemRole()
    },
    async updateSystemRole() {
      let res = await this.$API.SystemMenus.updateSystemRole(this.id, this.roleName, this.rolecode, this.timeArr, this.roleNote, this.sort)
      if (res.code == 200) {
        this.$message({ message: '修改成功', type: 'success' })
        this.$emit('close')
      }
    }
  }
}


</script>

<style ></style>